function GAD_Midazolam_PlaceCellProp_Bar_Plot(Placeness_MetaData)
%% collect G36 saline Proportion of Place Cell
for n=1:size(Placeness_MetaData,2)
    if contains(Placeness_MetaData(n).animalName,'G2_F6(2)_36') && Placeness_MetaData(n).dose==0 && contains(Placeness_MetaData(n).session, 'AM')
        G36_Saline(n,1)=Placeness_MetaData(n).PlaceCell_Proportion;
    end
end
G36_Saline(G36_Saline==0)=[];

%% collect G36 MIDA 0.25mg/kg Proportion of Place Cell
for n=1:size(Placeness_MetaData,2)
    if contains(Placeness_MetaData(n).animalName,'G2_F6(2)_36') && Placeness_MetaData(n).dose==0.25 && contains(Placeness_MetaData(n).session, 'AM')
        G36_MIDA025(n,1)=Placeness_MetaData(n).PlaceCell_Proportion;
    end
end
G36_MIDA025(G36_MIDA025==0)=[];

%% collect G36 MIDA 0.25mg/kg Proportion of Place Cell
for n=1:size(Placeness_MetaData,2)
    if contains(Placeness_MetaData(n).animalName,'G2_F6(2)_36') && Placeness_MetaData(n).dose==0.75 && contains(Placeness_MetaData(n).session, 'AM')
        G36_MIDA075(n,1)=Placeness_MetaData(n).PlaceCell_Proportion;
    end
end
G36_MIDA075(G36_MIDA075==0)=[];

%% collect G36 MIDA 1.25mg/kg Proportion of Place Cell
for n=1:size(Placeness_MetaData,2)
    if contains(Placeness_MetaData(n).animalName,'G2_F6(2)_36') && Placeness_MetaData(n).dose==1.25 && contains(Placeness_MetaData(n).session, 'AM')
        G36_MIDA125(n,1)=Placeness_MetaData(n).PlaceCell_Proportion;
    end
end
G36_MIDA125(G36_MIDA125==0)=[];

%% collect G36 MIDA 2.5mg/kg Proportion of Place Cell
for n=1:size(Placeness_MetaData,2)
    if contains(Placeness_MetaData(n).animalName,'G2_F6(2)_36') && Placeness_MetaData(n).dose==2.5 && contains(Placeness_MetaData(n).session, 'AM')
        G36_MIDA25(n,1)=Placeness_MetaData(n).PlaceCell_Proportion;
    end
end
G36_MIDA25(G36_MIDA25==0)=[];

%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%


%% collect G42 saline Proportion of Place Cell
for n=1:size(Placeness_MetaData,2)
    if contains(Placeness_MetaData(n).animalName,'G2_F6(2)_42') && Placeness_MetaData(n).dose==0 && contains(Placeness_MetaData(n).session, 'AM')
        G42_Saline(n,1)=Placeness_MetaData(n).PlaceCell_Proportion;
    end
end
G42_Saline(G42_Saline==0)=[];

%% collect G42 MIDA 0.25mg/kg Proportion of Place Cell
for n=1:size(Placeness_MetaData,2)
    if contains(Placeness_MetaData(n).animalName,'G2_F6(2)_42') && Placeness_MetaData(n).dose==0.25 && contains(Placeness_MetaData(n).session, 'AM')
        G42_MIDA025(n,1)=Placeness_MetaData(n).PlaceCell_Proportion;
    end
end
G42_MIDA025(G42_MIDA025==0)=[];

%% collect G42 MIDA 0.25mg/kg Proportion of Place Cell
for n=1:size(Placeness_MetaData,2)
    if contains(Placeness_MetaData(n).animalName,'G2_F6(2)_42') && Placeness_MetaData(n).dose==0.75 && contains(Placeness_MetaData(n).session, 'AM')
        G42_MIDA075(n,1)=Placeness_MetaData(n).PlaceCell_Proportion;
    end
end
G42_MIDA075(G42_MIDA075==0)=[];

%% collect G42 MIDA 1.25mg/kg Proportion of Place Cell
for n=1:size(Placeness_MetaData,2)
    if contains(Placeness_MetaData(n).animalName,'G2_F6(2)_42') && Placeness_MetaData(n).dose==1.25 && contains(Placeness_MetaData(n).session, 'AM')
        G42_MIDA125(n,1)=Placeness_MetaData(n).PlaceCell_Proportion;
    end
end
G42_MIDA125(G42_MIDA125==0)=[];

%% collect G42 MIDA 2.5mg/kg Proportion of Place Cell
for n=1:size(Placeness_MetaData,2)
    if contains(Placeness_MetaData(n).animalName,'G2_F6(2)_42') && Placeness_MetaData(n).dose==2.5 && contains(Placeness_MetaData(n).session, 'AM')
        G42_MIDA25(n,1)=Placeness_MetaData(n).PlaceCell_Proportion;
    end
end
G42_MIDA25(G42_MIDA25==0)=[];

%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%

%% plotting & data organization (a5-i-WT)

WT_Saline_Summary=cat(1, [], G42_Saline);
WT_MIDA025_Summary=cat(1, [], G42_MIDA025);
WT_MIDA075_Summary=cat(1, [], G42_MIDA075);
WT_MIDA125_Summary=cat(1, [], G42_MIDA125);
WT_MIDA25_Summary=cat(1, [], G42_MIDA25);

figure
A = categorical({'Saline'});
B = categorical({'0.25'});
C = categorical({'0.75'});
D = categorical({'1.25'});
E = categorical({'2.5'});
X = cat(2,A,B,C,D,E);
% X = reordercats(X,{'Saline','0.25','0.75,','1.25','2.5'});
Y(1,1) = mean(WT_Saline_Summary(:),'omitnan');
Y(1,2) = mean(WT_MIDA025_Summary(:),'omitnan');
Y(1,3) = mean(WT_MIDA075_Summary(:),'omitnan');
Y(1,4) = mean(WT_MIDA125_Summary(:),'omitnan');
Y(1,5) = mean(WT_MIDA25_Summary(:),'omitnan');
h=bar(X(1,1),Y(1,1),0.2,'LineWidth',1.2,'FaceColor','flat','FaceAlpha',0.5);
h.CData(1,:) = [0 0 1]; % color up each individual bar
ylabel('Proportion of Place Cell');
xlabel('Midazolam Dose (mg/kg)');
hold on
h=bar(X(1,2),Y(1,2),0.2,'LineWidth',1.2,'FaceColor','flat','FaceAlpha',0.2);
h.CData(1,:) = [1 0 0]; % color up each individual bar
hold on
h=bar(X(1,3),Y(1,3),0.2,'LineWidth',1.2,'FaceColor','flat','FaceAlpha',0.4);
h.CData(1,:) = [1 0 0]; % color up each individual bar
hold on
h=bar(X(1,4),Y(1,4),0.2,'LineWidth',1.2,'FaceColor','flat','FaceAlpha',0.6);
h.CData(1,:) = [1 0 0]; % color up each individual bar
hold on
h=bar(X(1,5),Y(1,5),0.2,'LineWidth',1.2,'FaceColor','flat','FaceAlpha',0.8);
h.CData(1,:) = [1 0 0]; % color up each individual bar
hold on
err(1,1)=calculate_standard_error(WT_Saline_Summary(:,1));
err(1,2)=calculate_standard_error(WT_MIDA025_Summary(:,1));
err(1,3)=calculate_standard_error(WT_MIDA075_Summary(:,1));
err(1,4)=calculate_standard_error(WT_MIDA125_Summary(:,1));
err(1,5)=calculate_standard_error(WT_MIDA25_Summary(:,1));
er = errorbar(X,Y,[],err,'LineWidth',2);    
er.Color = [0 0 0];                            
er.LineStyle = 'None'; 
ylim([0,0.2]);
set(gca,'FontSize',10);
hold on

% scatter plots with horizontal offsets - quick & dirty
% % half_num_animals_in_plot = 1;
% % initial_offset = -0.3;
% % offset = initial_offset;
% % 
% % sh = scatter(repmat(A,size(G36_Saline,1),1),G36_Saline(:,1),70,'o','k','LineWidth',2);
% % offset = offset - (initial_offset/half_num_animals_in_plot);
% % sh.XData = double(sh.XData) + offset;
% % 
% % sh = scatter(repmat(A,size(G42_Saline,1),1),G42_Saline(:,1),70,'o','b','LineWidth',2);
% % offset = offset - 0.75*(initial_offset/half_num_animals_in_plot);
% % sh.XData = double(sh.XData) + offset;
% % 
% % 
% % half_num_animals_in_plot = 1;
% % initial_offset = -0.3;
% % offset = initial_offset;
% % 
% % sh = scatter(repmat(B,size(G36_MIDA025,1),1),G36_MIDA025(:,1),70,'o','k','LineWidth',2);
% % offset = offset - (initial_offset/half_num_animals_in_plot);
% % sh.XData = double(sh.XData) + offset;
% % 
% % sh = scatter(repmat(B,size(G42_MIDA025,1),1),G42_MIDA025(:,1),70,'o','b','LineWidth',2);
% % offset = offset - 0.75*(initial_offset/half_num_animals_in_plot);
% % sh.XData = double(sh.XData) + offset;
% % 
% % 
% % half_num_animals_in_plot = 1;
% % initial_offset = -0.3;
% % offset = initial_offset;
% % 
% % sh = scatter(repmat(B,size(G36_MIDA075,1),1),G36_MIDA075(:,1),70,'o','k','LineWidth',2);
% % offset = offset - (initial_offset/half_num_animals_in_plot);
% % sh.XData = double(sh.XData) + offset;
% % 
% % sh = scatter(repmat(B,size(G42_MIDA075,1),1),G42_MIDA075(:,1),70,'o','b','LineWidth',2);
% % offset = offset - 0.75*(initial_offset/half_num_animals_in_plot);
% % sh.XData = double(sh.XData) + offset;
% % 
% % 
% % half_num_animals_in_plot = 1;
% % initial_offset = -0.3;
% % offset = initial_offset;
% % 
% % sh = scatter(repmat(E,size(G36_MIDA125,1),1),G36_MIDA125(:,1),70,'o','k','LineWidth',2);
% % offset = offset - (initial_offset/half_num_animals_in_plot);
% % sh.XData = double(sh.XData) + offset;
% % 
% % sh = scatter(repmat(E,size(G42_MIDA125,1),1),G42_MIDA125(:,1),70,'o','b','LineWidth',2);
% % offset = offset - 0.75*(initial_offset/half_num_animals_in_plot);
% % sh.XData = double(sh.XData) + offset;
% % 
% % 
% % 
% % half_num_animals_in_plot = 1;
% % initial_offset = -0.3;
% % offset = initial_offset;
% % 
% % sh = scatter(repmat(E,size(G36_MIDA25,1),1),G36_MIDA25(:,1),70,'o','k','LineWidth',2);
% % offset = offset - (initial_offset/half_num_animals_in_plot);
% % sh.XData = double(sh.XData) + offset;
% % 
% % sh = scatter(repmat(E,size(G42_MIDA25,1),1),G42_MIDA25(:,1),70,'o','b','LineWidth',2);
% % offset = offset - 0.75*(initial_offset/half_num_animals_in_plot);
% % sh.XData = double(sh.XData) + offset;


% title('C57 Midazolam DataSet Proportion of Place Cell','FontSize',15);

%% plotting & data organization (a5-i-KO)

KO_Saline_Summary=cat(1, [], G36_Saline);
KO_MIDA025_Summary=cat(1, [], G36_MIDA025);
KO_MIDA075_Summary=cat(1, [], G36_MIDA075);
KO_MIDA125_Summary=cat(1, [], G36_MIDA125);
KO_MIDA25_Summary=cat(1, [], G36_MIDA25);

figure
A = categorical({'Saline'});
B = categorical({'0.25'});
C = categorical({'0.75'});
D = categorical({'1.25'});
E = categorical({'2.5'});
X = cat(2,A,B,C,D,E);
% X = reordercats(X,{'Saline','0.25','0.75,','1.25','2.5'};
Y(1,1) = mean(KO_Saline_Summary(:),'omitnan');
Y(1,2) = mean(KO_MIDA025_Summary(:),'omitnan');
Y(1,3) = mean(KO_MIDA075_Summary(:),'omitnan');
Y(1,4) = mean(KO_MIDA125_Summary(:),'omitnan');
Y(1,5) = mean(KO_MIDA25_Summary(:),'omitnan');
h=bar(X(1,1),Y(1,1),0.2,'LineWidth',1.2,'FaceColor','flat','FaceAlpha',0.5);
h.CData(1,:) = [0 0 1]; % color up each individual bar
ylabel('Proportion of Place Cell');
xlabel('Midazolam Dose (mg/kg)');
hold on
h=bar(X(1,2),Y(1,2),0.2,'LineWidth',1.2,'FaceColor','flat','FaceAlpha',0.2);
h.CData(1,:) = [1 0 0]; % color up each individual bar
hold on
h=bar(X(1,3),Y(1,3),0.2,'LineWidth',1.2,'FaceColor','flat','FaceAlpha',0.4);
h.CData(1,:) = [1 0 0]; % color up each individual bar
hold on
h=bar(X(1,4),Y(1,4),0.2,'LineWidth',1.2,'FaceColor','flat','FaceAlpha',0.6);
h.CData(1,:) = [1 0 0]; % color up each individual bar
hold on
h=bar(X(1,5),Y(1,5),0.2,'LineWidth',1.2,'FaceColor','flat','FaceAlpha',0.8);
h.CData(1,:) = [1 0 0]; % color up each individual bar
hold on
err(1,1)=calculate_standard_error(KO_Saline_Summary(:,1));
err(1,2)=calculate_standard_error(KO_MIDA025_Summary(:,1));
err(1,3)=calculate_standard_error(KO_MIDA075_Summary(:,1));
err(1,4)=calculate_standard_error(KO_MIDA125_Summary(:,1));
err(1,5)=calculate_standard_error(KO_MIDA25_Summary(:,1));
er = errorbar(X,Y,[],err,'LineWidth',2);    
er.Color = [0 0 0];                            
er.LineStyle = 'None'; 
ylim([0,0.2]);
set(gca,'FontSize',10);
hold on

end